var API = API || {};

$(document).ready(function() {

    // Custom combox
    $('.dropdownized').dropdownized();

    // Currency dropdown live change handler
    $('#currency').live('change', function() {

        var glue = "?";
        var url = $(this).attr('data-url');
        var currency = $(this).val();

        // is there quetion mark in query string
        myIndexOf = url.indexOf('?');
        if (myIndexOf !== -1) {
            glue = "&";
        }


        window.location.href = url + glue + "currency=" + currency;

    });

    $(".tooltip").tooltip({
        show: {
            delay: 250
        },
        track: true
    });

    //home poage
    if (method === "index") {
        
        if (do_special) {
            // Bx Slider
            $('.bxslider').bxSlider({
                mode: 'fade',
                auto: ($("#special_popular>li").length > 1) ? true: false,
                pause: 6000,
                speed: 1500,
                easing: 'linear',
                pager: false,
                controls: false,
                autoHover: true
            });
        }

        var link_home = $("#special_popular li:first-child").find('a').attr('href');
        $('.special-deals a').attr('href', link_home);

    }

});